<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8"/>
    <title>Title</title>
    <link rel="stylesheet" th:href="@{/layui/layui.css}"  media="all" />
    <link rel="stylesheet" th:href="@{/css/daohang.css}" />
    <script th:src="@{/layui/layui.all.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/jquery-3.2.1.js}"></script>
    <link rel="stylesheet" th:href="@{/css/main.css}" />
    <link rel="stylesheet" type="text/css" th:href="@{/css/search.css}"/>

</head>
<body bgcolor="">
<!--轮播图片-->
<div class="layui-carousel" id="test1">
    <div carousel-item="">
        <div><img src="image/lun.jpg" width="100%" height="100%"/></div>
        <div><img src="image/lun2.jpg" width="100%" height="100%"/></div>
        <div><img src="image/13.jpg" width="100%" height="120%"/></div>
    </div>
</div>
<script>
    layui.use('carousel', function () {
        var carousel = layui.carousel;
        //建造实例
        carousel.render({
            elem: '#test1'
            , width: '100%' //设置容器宽度
            , arrow: 'none' //始终显示箭头
            , width: '1080px'
            , height: '150px'
            //,anim: 'updown' //切换动画方式
        });
    });
</script>
<fieldset class="layui-elem-field layui-field-title" >
    <legend><span class="" style="font-size: 14px">
        <a href="/dor/indexdemo">首页<span class="layui-box">&gt;</span></a>
  <span>查寝情况<span class="layui-box">&gt;</span></span>
     <a href="/dor/heaSelect">卫生情况<span class="layui-box">&gt;</span></a>
        <span>添加卫生检查<span class="layui-box">&gt;</span></span>
</span>
    </legend>
</fieldset>


<div style="position: relative;left: 10px;">
    <select id="build" class="search_select"></select>
    <select id="room" class="search_select"></select>
    <select id="rank" class="search_select">
        <option value="优">优</option>
        <option value="良">良</option>
        <option value="中">中</option>
        <option value="差">差</option>
    </select>
    <br/>
    <div class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">检查日期</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" name="date" id="test2" required="required"/>
            </div>
        </div>
    </div>
    <button id="submitScore" class="layui-btn layui-btn-normal">提交</button>
</div>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#test2'
            ,format: 'yyyy/MM/dd'
        });
    });
</script>
<script>
    $.get('/dor/build', function (data) {
//        console.log(data)
        buildList = '<option>选择楼栋</option>'
        data.forEach(function (value) {
//            console.log(value)
            buildList+='<option>'+value.build_id+'</option>'
        })
//        console.log(buildList)
        $("#build").html(buildList)
    })

    $("#build").on('click', function () {
        var build = $("#build").val()
        console.log('0'+build)
        $.get('/dor/rooms/'+build, function (data) {
//        console.log(data)
            buildList = '<option>选择寝室</option>'
            data.forEach(function (value) {
//            console.log(value)
                buildList+='<option value="'+value.id+'">'+value.room_id+'</option>'
            })
//            console.log(buildList)
            $("#room").html(buildList)
        })
    })
    /*<![CDATA[*/
    $("#submitScore").on('click', function () {
        roomid = $("#room").val()
        ranks = $("#rank").val()
        date = $("#test2").val()

        $.get('/dor/addHealth?id='+roomid+'&rank='+ranks+'&date='+date, function (data) {
//            console.log(data)
            if(data==='Already'){
                layer.msg('你已经添加该寝室今天的卫生情况')
            }else{
                layer.msg('添加成功，请继续添加')
            }

        })
    })
    /*]]>*/
    var date = new Date()
    var years = date.getYear()+1900;
    var month = date.getMonth()+1
    var day = date.getDate()
    var result = years+"/"+month+"/"+day;
//    console.log(result)
    $("#test2").val(result)


</script>

</body>
</html>